<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="h" uri="/syzg-html"%>
<!DOCTYPE html>
<html>
<body>
<div class="modal fade bs-example-modal-lg" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">新增模块信息</h4>
      </div>
      <div class="modal-body" id="modalCore">
        <form class="form-horizontal" role="form" id="aeForm" name="aeForm">
          <fieldset>
            <!-- generate code start -->

            <div class="form-group">
              <label class="col-sm-2 control-label" for="code">模块编码</label>
              <div class="col-sm-3">
                <input type="text" id="code" name="code" class="form-control" />
              </div>

              <label class="col-sm-2 control-label" for="name">模块名称</label>
              <div class="col-sm-3">
                <input type="text" id="name" name="name" class="form-control" />
              </div>
            </div>
            
            <div class="form-group">
              <label class="col-sm-2 control-label" for="leafFlag">是否叶子节点</label>
              <div class="col-sm-3">
              	<label class="radio-inline">
                	<input type="radio" name="leafFlag" value="1" onclick="filterLeafFlag(this.value)"/> 是
                </label>
                <label class="radio-inline">
                	<input type="radio" name="leafFlag" value="0" onclick="filterLeafFlag(this.value)" checked="checked"/> 否
                </label>
              </div>

              <label class="col-sm-2 control-label" for="name">同级序列</label>
              <div class="col-sm-3">
                <input type="text" name="orderNo" id="orderNo" class="form-control" />
              </div>
            </div>
            <div class="form-group" id="iconStyleRow">
              <label class="col-sm-2 control-label" for="href">图标样式</label>
              <div class="col-sm-8">
                <input type="text" id="iconStyle" name="iconStyle" class="form-control" />
              </div>
            </div>

            <div class="form-group" id="hrefRow" style="display: none;">
              <label class="col-sm-2 control-label" for="href">链接地址</label>
              <div class="col-sm-8">
                <input type="text" id="href" name="href" class="form-control" />
              </div>
            </div>
            
            <div class="form-group" id="parentModuleRow" style="display: none;">
              <label class="col-sm-2 control-label" for="parentModule.id">父模块</label>
              <div class="col-sm-3">
              	<select name="parentModule.id" id="parentModule.id" class="form-control">
              	  <c:forEach items="${moduleList }" var="parentModule">
              		  <option value="${parentModule.id }">${parentModule.name }</option>
              	  </c:forEach>
              	</select>
              </div>
            </div>

			<!-- generate code end -->
          </fieldset>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary" onclick="submitSave('add');">保存</button>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
$('#aeForm').bootstrapValidator({
  message: 'This value is not valid',
  feedbackIcons: {
      valid: 'glyphicon glyphicon-ok',
      invalid: 'glyphicon glyphicon-remove',
      validating: 'glyphicon glyphicon-refresh'
  },
  fields: {
	  code: {
    	  group: '.col-sm-3',
          message: '请输入正确的格式',
          validators: {
              notEmpty: {
                  message: '模块代码不能为空'
              }
          }
      },
      name: {
    	  group: '.col-sm-3',
          message: '请输入正确的格式',
          validators: {
              notEmpty: {
                  message: '模块名称不能为空'
              }
          }
      },
      href: {
    	  group: '.col-sm-8',
          message: '请输入正确的格式',
          validators: {
              notEmpty: {
                  message: '链接地址不能为空'
              }
          }
      },
      orderNo: {
    	  group: '.col-sm-3',
          message: '请输入正确的格式',
          validators: {
              notEmpty: {
                  message: '同级序列不能为空'
              },regexp: {
                  regexp: /^[1-9]\d*$/,
                  message: '同级序列必须为正整数'
              }
          }
      }
  	}
}).on('success.form.bv', function(e, data) {
	FormFunction.submitSave('add');
});
function filterLeafFlag(value){
    if(value=='0'){
       $("#parentModuleRow").hide();
       $("#hrefRow").hide();
       $("#href").val("#");
    } else {
       $("#parentModuleRow").show();
       $("#hrefRow").show();
       //$("#operationRow").show();
    }
}
</script>
</body>
</html>

